﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace AL100.BankApplication.BLL
{
    /// <summary>
    /// Base class for all Persons.
    /// </summary>
    public class Person
    {

        private string  _name;
        private string  _firstName;
        private int     _yearOfBirth;


        public Person(string name, string firstName)
        {
            Name       = name;
            FirstName  = firstName;
        }


        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        public string Name
        {
            get { return _name; }
            set
            {
                _name = value.ToUpper();
            }
        }

        /// <summary>
        /// Gets or sets the first name.
        /// </summary>
        public string FirstName
        {
            get { return _firstName; }
            set
            {
                if (value.Length > 12)
                {
                    value = value.Substring(0, 12);
                }
                _firstName = value;
            }
        }

        /// <summary>
        /// Gets or sets the year of birth.
        /// </summary>
        public int YearOfBirth
        {
            get { return _yearOfBirth; }
            set
            {
                int currentYear = DateTime.Now.Year;

                if (value < currentYear - 100 || value > currentYear)
                {
                    value = 0;
                }
                _yearOfBirth = value;
            }
        }

        /// <summary>
        /// Gets the year of birth.
        /// </summary>
        public int Age
        {
            get { return _yearOfBirth == 0 ? _yearOfBirth : DateTime.Now.Year - _yearOfBirth; }
        }







    }

    
}
